package com.eversec.thread;

import com.eversec.dao.FeatureRepository;
import com.eversec.domain.FeatureModel;
import com.eversec.util.MD5Util;

import java.util.Date;

/**
 * Created by eversec on 2017/7/12.
 */
public class InsertThread implements Runnable {

    private FeatureRepository repository ;
    public InsertThread(FeatureRepository repository) {

        this.repository = repository ;
    }

    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    @Override
    public void run() {

        FeatureModel model = new FeatureModel();
        model.setFrequency(MD5Util.getFrequency());
        model.setMd5(MD5Util.getMD5());
        model.setReporttime(new Date());
        repository.insert(model);

    }
}
